using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace Impact.Model.Objects
{
	/// <summary>
	/// Strongly-typed collection for the RssSubscriber class.
	/// </summary>
    [Serializable]
	public partial class RssSubscriberCollection : ActiveList<RssSubscriber, RssSubscriberCollection>
	{	   
		public RssSubscriberCollection() {}
	}
	/// <summary>
	/// This is an ActiveRecord class which wraps the impact_RssSubscribers table.
	/// </summary>
	[Serializable]
	public partial class RssSubscriber : ActiveRecord<RssSubscriber>, IActiveRecord
	{
		#region .ctors and Default Settings
		
		public RssSubscriber()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}
		
		private void InitSetDefaults() { SetDefaults(); }
		
		public RssSubscriber(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}
        
		public RssSubscriber(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}
		 
		public RssSubscriber(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}
		
		protected static void SetSQLProps() { GetTableSchema(); }
		
		#endregion
		
		#region Schema and Query Accessor	
		public static Query CreateQuery() { return new Query(Schema); }
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}
		}
		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("impact_RssSubscribers", TableType.Table, DataService.GetInstance("ImpactProvider"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarSubscriberId = new TableSchema.TableColumn(schema);
				colvarSubscriberId.ColumnName = "SubscriberId";
				colvarSubscriberId.DataType = DbType.Int32;
				colvarSubscriberId.MaxLength = 0;
				colvarSubscriberId.AutoIncrement = true;
				colvarSubscriberId.IsNullable = false;
				colvarSubscriberId.IsPrimaryKey = true;
				colvarSubscriberId.IsForeignKey = false;
				colvarSubscriberId.IsReadOnly = false;
				colvarSubscriberId.DefaultSetting = @"";
				colvarSubscriberId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSubscriberId);
				
				TableSchema.TableColumn colvarUsername = new TableSchema.TableColumn(schema);
				colvarUsername.ColumnName = "Username";
				colvarUsername.DataType = DbType.AnsiString;
				colvarUsername.MaxLength = 50;
				colvarUsername.AutoIncrement = false;
				colvarUsername.IsNullable = true;
				colvarUsername.IsPrimaryKey = false;
				colvarUsername.IsForeignKey = false;
				colvarUsername.IsReadOnly = false;
				colvarUsername.DefaultSetting = @"";
				colvarUsername.ForeignKeyTableName = "";
				schema.Columns.Add(colvarUsername);
				
				TableSchema.TableColumn colvarChannelName = new TableSchema.TableColumn(schema);
				colvarChannelName.ColumnName = "ChannelName";
				colvarChannelName.DataType = DbType.AnsiString;
				colvarChannelName.MaxLength = 50;
				colvarChannelName.AutoIncrement = false;
				colvarChannelName.IsNullable = true;
				colvarChannelName.IsPrimaryKey = false;
				colvarChannelName.IsForeignKey = false;
				colvarChannelName.IsReadOnly = false;
				colvarChannelName.DefaultSetting = @"";
				colvarChannelName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarChannelName);
				
				TableSchema.TableColumn colvarIpAddress = new TableSchema.TableColumn(schema);
				colvarIpAddress.ColumnName = "IpAddress";
				colvarIpAddress.DataType = DbType.AnsiString;
				colvarIpAddress.MaxLength = 50;
				colvarIpAddress.AutoIncrement = false;
				colvarIpAddress.IsNullable = true;
				colvarIpAddress.IsPrimaryKey = false;
				colvarIpAddress.IsForeignKey = false;
				colvarIpAddress.IsReadOnly = false;
				colvarIpAddress.DefaultSetting = @"";
				colvarIpAddress.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIpAddress);
				
				TableSchema.TableColumn colvarRequestDate = new TableSchema.TableColumn(schema);
				colvarRequestDate.ColumnName = "RequestDate";
				colvarRequestDate.DataType = DbType.DateTime;
				colvarRequestDate.MaxLength = 0;
				colvarRequestDate.AutoIncrement = false;
				colvarRequestDate.IsNullable = false;
				colvarRequestDate.IsPrimaryKey = false;
				colvarRequestDate.IsForeignKey = false;
				colvarRequestDate.IsReadOnly = false;
				colvarRequestDate.DefaultSetting = @"";
				colvarRequestDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarRequestDate);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["ImpactProvider"].AddSchema("impact_RssSubscribers",schema);
			}
		}
		#endregion
		
		#region Props
		  
		[XmlAttribute("SubscriberId")]
		[Bindable(true)]
		public int SubscriberId 
		{
			get { return GetColumnValue<int>(Columns.SubscriberId); }
			set { SetColumnValue(Columns.SubscriberId, value); }
		}
		  
		[XmlAttribute("Username")]
		[Bindable(true)]
		public string Username 
		{
			get { return GetColumnValue<string>(Columns.Username); }
			set { SetColumnValue(Columns.Username, value); }
		}
		  
		[XmlAttribute("ChannelName")]
		[Bindable(true)]
		public string ChannelName 
		{
			get { return GetColumnValue<string>(Columns.ChannelName); }
			set { SetColumnValue(Columns.ChannelName, value); }
		}
		  
		[XmlAttribute("IpAddress")]
		[Bindable(true)]
		public string IpAddress 
		{
			get { return GetColumnValue<string>(Columns.IpAddress); }
			set { SetColumnValue(Columns.IpAddress, value); }
		}
		  
		[XmlAttribute("RequestDate")]
		[Bindable(true)]
		public DateTime RequestDate 
		{
			get { return GetColumnValue<DateTime>(Columns.RequestDate); }
			set { SetColumnValue(Columns.RequestDate, value); }
		}
		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
        
        
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(string varUsername,string varChannelName,string varIpAddress,DateTime varRequestDate)
		{
			RssSubscriber item = new RssSubscriber();
			
			item.Username = varUsername;
			
			item.ChannelName = varChannelName;
			
			item.IpAddress = varIpAddress;
			
			item.RequestDate = varRequestDate;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}
		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(int varSubscriberId,string varUsername,string varChannelName,string varIpAddress,DateTime varRequestDate)
		{
			RssSubscriber item = new RssSubscriber();
			
				item.SubscriberId = varSubscriberId;
			
				item.Username = varUsername;
			
				item.ChannelName = varChannelName;
			
				item.IpAddress = varIpAddress;
			
				item.RequestDate = varRequestDate;
			
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}
		#endregion
        
        
        
        #region Typed Columns
        
        
        public static TableSchema.TableColumn SubscriberIdColumn
        {
            get { return Schema.Columns[0]; }
        }
        
        
        
        public static TableSchema.TableColumn UsernameColumn
        {
            get { return Schema.Columns[1]; }
        }
        
        
        
        public static TableSchema.TableColumn ChannelNameColumn
        {
            get { return Schema.Columns[2]; }
        }
        
        
        
        public static TableSchema.TableColumn IpAddressColumn
        {
            get { return Schema.Columns[3]; }
        }
        
        
        
        public static TableSchema.TableColumn RequestDateColumn
        {
            get { return Schema.Columns[4]; }
        }
        
        
        
        #endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string SubscriberId = @"SubscriberId";
			 public static string Username = @"Username";
			 public static string ChannelName = @"ChannelName";
			 public static string IpAddress = @"IpAddress";
			 public static string RequestDate = @"RequestDate";
						
		}
		#endregion
		
		#region Update PK Collections
		
        #endregion
    
        #region Deep Save
		
        #endregion
	}
}
